package com.example.saiweisi.controller.systemAdminController;

import com.example.saiweisi.common.Result;
import com.example.saiweisi.controller.request.PageBaseRequest;
import com.example.saiweisi.model.WashKind;
import com.example.saiweisi.service.interf.IWashKindService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/washkind")
@RestController
@CrossOrigin
@Slf4j
public class WashKindController {
    @Autowired
    private IWashKindService washKindService;
    //分页查询所有会员种类
    @GetMapping("/page")
    public Result page(PageBaseRequest pageBaseRequest) {
        return Result.success(washKindService.page(pageBaseRequest));
    }
    //查找所有的洗衣方式种类
    @GetMapping("/getall")
    public Result getall() {
        return Result.success(washKindService.getAllWashKind());
    }
    //添加会员种类
    @PostMapping("/add")
    public Result addwashkind(@RequestBody WashKind washKind){
        washKindService.addwashkind(washKind);
        return Result.success();
    }
    //删除会员种类
    @DeleteMapping("/delete{washKindId}")
    public Result deletewashlind(@PathVariable Integer washKindId){
        System.out.println("sbsbsbsbbsbbsbsbsbs");
        System.out.println(washKindId);
        washKindService.deletewashkind(washKindId);
        return Result.success();
    }
    //根据id查找会员种类信息并返回前端，作为修改表单数据携带
    @GetMapping("/{washKindId}")
    public Result getById(@PathVariable Integer washKindId){
        WashKind washKind=washKindService.getById(washKindId);
        return Result.success(washKind);
    }
    @PutMapping("/update")
    public Result updatewashkind(@RequestBody WashKind washKind){
        washKindService.updatewashkind(washKind);
        return Result.success();
    }
}
